package com.du.cloud.common.base.utils;

import cn.hutool.crypto.SecureUtil;
import com.du.cloud.common.base.constant.CommonConstants;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * Desc: 密码加密
 * Author: dushuang
 * Date: 2020/6/5
 **/
public class PassUtil {

    /**
     * 密码加密
     * MD5(salt + md5pass + loginName)
     * @param password  密码
     * @param loginName 用户名
     * @return
     */
    public static String encryptPass(String password, String loginName){
//        System.out.println(MD5Util.getMd5Value(
//                WebSystemConstant.SYS_USER_SALT
//                        .concat(password)
//                        .concat(loginName)));
        return SecureUtil.md5(
                CommonConstants.SYS_USER_SALT
                        .concat(password)
                        .concat(loginName)
        );
    }

    public static void main(String[] args) {
        System.out.println(new BCryptPasswordEncoder().encode(SecureUtil.md5("1")));
    }
}
